! 数组构造器
program main
    integer :: ntimesteps
    real, allocatable :: dat(:)
    real :: rand

    call random_number(rand)
    ntimesteps = nint(min(max(rand*50, 5.0), 50.0))

    allocate (dat(0))
    do i = 1, ntimesteps
        call random_number(rand)
        dat = [dat, rand]  ! 数组构造器，编译器会对其进行优化
    end do

    print *, dat

end program main
